﻿using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using MyImdb.Views;
using System.Windows;
using System.Windows.Input;

namespace MyImdb.ViewModel
{
    internal class MainWindowViewModel: ViewModelBase
    {
        private UIElement _AppContent;
        public UIElement AppContent
        {
            get { return _AppContent; }
            set
            {
                _AppContent = value;
                RaisePropertyChanged("AppContent");
            }
        }

        private bool _IsHomeEnabled;
        public bool IsHomeEnabled
        {
            get { return _IsHomeEnabled; }
            set
            {
                _IsHomeEnabled = value;
                RaisePropertyChanged("IsHomeEnabled");
            }
        }

        private ICommand _HomeCommand;
        public ICommand HomeCommand
        {
            get { return _HomeCommand; }
            set
            {
                _HomeCommand = value;
                RaisePropertyChanged("HomeCommand");
            }
        }

        private ICommand _SearchCommand;
        public ICommand SearchCommand
        {
            get { return _SearchCommand; }
            set
            {
                _SearchCommand = value;
                RaisePropertyChanged("SearchCommand");
            }
        }

        private ICommand _SearchLocalCommand;
        public ICommand SearchLocalCommand
        {
            get { return _SearchLocalCommand; }
            set
            {
                _SearchLocalCommand = value;
                RaisePropertyChanged("SearchLocalCommand");
            }
        }

        private ICommand _ViewAllCommand;
        public ICommand ViewAllCommand
        {
            get { return _ViewAllCommand; }
            set
            {
                _ViewAllCommand = value;
                RaisePropertyChanged("ViewAllCommand");
            }
        }

        private ICommand _SettingsCommand;
        public ICommand SettingsCommand
        {
            get { return _SettingsCommand; }
            set
            {
                _SettingsCommand = value;
                RaisePropertyChanged("SettingsCommand");
            }
        }

        public MainWindowViewModel()
        {
            AppContent = new StartView();
            HomeCommand = new RelayCommand(NavigateHome);
            SearchCommand = new RelayCommand(NavigateSearch);
            SearchLocalCommand = new RelayCommand(NavigateSearchLocal);
            ViewAllCommand = new RelayCommand(NavigateViewAll);
            SettingsCommand = new RelayCommand(Settings);
        }

        private void NavigateHome()
        {
            AppContent = new StartView();
            IsHomeEnabled = false;
        }

        private void NavigateSearch()
        {
            AppContent = new SearchView();
            IsHomeEnabled = true;
        }

        private void NavigateSearchLocal()
        {
            AppContent = new SearchLocalView();
            IsHomeEnabled = true;
        }

        private void NavigateViewAll()
        {
            AppContent = new AllItemsView();
            IsHomeEnabled = true;
        }

        private void Settings()
        {
            AppContent = new SettingsView();
            IsHomeEnabled = true;
        }
    }
}
